package com.ruoyi.develop.goodsInvoiceApplyDetail.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;

import com.ruoyi.develop.projectBaseInfo.domain.ProjectBaseInfo;
import com.ruoyi.develop.projectBaseInfo.service.IProjectBaseInfoService;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.goodsInvoiceApplyDetail.mapper.GoodsInvoiceApplyDetailMapper;
import com.ruoyi.develop.goodsInvoiceApplyDetail.domain.GoodsInvoiceApplyDetail;
import com.ruoyi.develop.goodsInvoiceApplyDetail.service.IGoodsInvoiceApplyDetailService;

/**
 * 发票申请明细Service业务层处理
 * @author qh
 * @date 2025-04-26
 */
@Service
public class GoodsInvoiceApplyDetailServiceImpl implements IGoodsInvoiceApplyDetailService {
    @Resource
    private GoodsInvoiceApplyDetailMapper goodsInvoiceApplyDetailMapper;
    @Resource
    private IProjectBaseInfoService projectBaseInfoService;

    /**
     * 查询发票申请明细
     * @param id 发票申请明细主键
     * @return 发票申请明细
     */
    @Override
    public GoodsInvoiceApplyDetail selectById(String id) {
        return goodsInvoiceApplyDetailMapper.selectById(id);
    }

    /**
     * 查询发票申请明细列表
     * @param entity 发票申请明细
     * @return 发票申请明细
     */
    @Override
    public List<GoodsInvoiceApplyDetail> selectList(GoodsInvoiceApplyDetail entity) {
        return goodsInvoiceApplyDetailMapper.selectList(entity);
    }

    /**
     * 新增发票申请明细
     * @param entity 发票申请明细
     * @return 结果
     */
    @Override
    public int insert(GoodsInvoiceApplyDetail entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return goodsInvoiceApplyDetailMapper.insert(entity);
    }

    /**
     * 修改发票申请明细
     * @param entity 发票申请明细
     * @return 结果
     */
    @Override
    public int update(GoodsInvoiceApplyDetail entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return goodsInvoiceApplyDetailMapper.update(entity);
    }

    /**
     * 批量删除发票申请明细
     * @param ids 需要删除的发票申请明细主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return goodsInvoiceApplyDetailMapper.deleteByIds(ids);
    }

    /**
     * 删除发票申请明细信息
     * @param id 发票申请明细主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return goodsInvoiceApplyDetailMapper.deleteById(id);
    }

    @Override
    public BigDecimal selectSumTaxByProjectId(String projectId) {
        return goodsInvoiceApplyDetailMapper.selectSumTaxByProjectId(projectId);
    }

    @Override
    public BigDecimal selectSumBackMoneyByProjectId(String projectId) {
        return goodsInvoiceApplyDetailMapper.selectSumBackMoneyByProjectId(projectId);
    }


}
